package com.os.core.common;

import lombok.Data;

@Data
public class JsonResult
{
    private Integer code = 10000;

    private String msg = "success";

    private Object data;

    private boolean success;

    public JsonResult()
    {
    }

    public JsonResult(boolean success)
    {
        this.success = success;
    }

    public JsonResult(boolean success, Object o)
    {
        this.success = success;
        this.data = o;
    }

    public JsonResult(boolean success, ResultCode apiCode)
    {
        this.success = success;
        this.code = apiCode.getCode();
        this.msg = apiCode.getMsg();
    }

    public JsonResult(boolean success, ResultCode apiCode, String msg)
    {
        this.success = success;
        this.code = apiCode.getCode();
        this.msg = msg;
    }

    public JsonResult(boolean success, ResultCode apiCode, Object o)
    {
        this.success = success;
        this.data = o;
        this.code = apiCode.getCode();
        this.msg = apiCode.getMsg();
    }

    public static JsonResult returnResponse()
    {
        return new JsonResult(true, ResultCode.SERVICE_OK);
    }

    public static JsonResult returnResponse(boolean success)
    {
        return new JsonResult(success);
    }

    public static JsonResult returnResponse(Object data)
    {
        return new JsonResult(true, data);
    }

    public static JsonResult returnResponse(boolean success, ResultCode apiCode)
    {
        return new JsonResult(success, apiCode);
    }

    public static JsonResult returnResponse(boolean success, ResultCode apiCode, String msg)
    {
        return new JsonResult(success, apiCode, msg);
    }

    public static JsonResult returnResponse(boolean success, ResultCode apiCode, Object data)
    {
        return new JsonResult(success, apiCode, data);
    }

    public void failEnum(ResultCode resultCode)
    {
//        this.setCode(resultCode.getCode());
//        this.setMsg(resultCode.getMsg());
    }

    public void success(String reason)
    {
//        this.setCode(10000);
//        this.setMsg(reason);
    }
}
